﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aerthe.Model.Tasks
{
    public class MTask2
    {
        public List<ListsItem> ListTask = new List<ListsItem> { };
        //string BuforString;

        public MTask2()
        {
            using (var Base = new NorthwindEntities())
            {
                var MaxRabat = Base.Order_Details.Max(o => o.Discount);

                var ListProducts = Base.Products.Select(m => new
                {
                    InfoProduct = m,
                    ValueRabat = m.Order_Details.Where(n => n.Discount == MaxRabat)
                });

                foreach (var a in ListProducts)
                {
                    this.ListTask.Add(new ListsItem(a.InfoProduct.ProductName, MaxRabat.ToString()));
                }
            }
        }

        public void MViewConsole()
        {
            Console.WriteLine("|  {0,-35} |  {1}\n", "Product Name", "Rabat");

            foreach (var a in this.ListTask)
            {
                Console.WriteLine("|  {0,-35} |  {1} %", a.Item1, a.Item2);
            }
        }
    }
}
